package com.cn.wanxi.servlet;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/home")
public class HomeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

//Request请求对象：servlet的作用域？
// request ,指对请求页面有效
// session , 整个会话期有效，清楚浏览器缓存就没有了，跨浏览器就没有了
// application 整个会话期，可以跨浏览器
//        req.setAttribute("aa", "bb");
//        页面转发
//        req.getRequestDispatcher("/jsp/home.jsp").forward(req, resp);
        String aa = "bb";
        resp.getWriter().println(JSONObject.toJSONString(aa));
    }
}
